Add support for Google Takeout Location History (#1160)
authorTyler MacDonald <postmaxin@users.noreply.github.com>
Mon, 28 Aug 2023 22:31:04 +0000 (18:31 -0400)
committerGitHub <noreply@github.com>
Mon, 28 Aug 2023 22:31:04 +0000 (16:31 -0600)
commitfb0480216312cbb3d255dadf1a30d9cb1e479261
tree98cee8ca3cec697fd195339ce185743eda135ba3
parent34ab49034267fd6c00a431c05fdb654f6cdd6c6d
Add support for Google Takeout Location History (#1160)

* Add support for Google Takeout Location History

This adds support for parsing the location history provided by Google Takeout.
This makes it possible to convert a month's, year's, or your entire location
history at once instead of having to export one day's history at a time on
Google Maps.

There is documentation in the `xmldoc` folder with some examples.

It works great, but there are one, possibly two, other additions I'd like to
make in following diffs:

1. Add the ability to select date ranges. For example, I went on a road trip
   that started in the last week of February, but right now I can only select
 tracks at the resolution of a whole month.

2. Add support for the higher-resolution "roadSegment" blocks in newer
   "activitySegment" blocks. This will have to be optional as you have to
 query the Google Maps API to get lat/long, which costs money. However,
 if you're willing to pay for it, you can get great detail out of it.
 They look like this:

```
       "roadSegment": [{
          "placeId": "ChIJBdXmuuWaK4gRoiClERhZcy8",
          "duration": "76s"
        }, {
          "placeId": "ChIJ4ekNlOWaK4gRxu-moMRFo60",
          "duration": "58s"
        }, {
          "placeId": "ChIJ10qEheWaK4gRQ1T24wEuuN4",
          "duration": "58s"
        }, {
          "placeId": "ChIJe7NWfu-aK4gRFHBB6P0PMe4",
          "duration": "58s"
[...]
```

* rename variable

* this TODO is done

* now builds on focal, fix documentation

* patch -p2 < ~/testo.log

* use `&&` instead of `and` for old compilers

* don't leak objects when we skip events at exact lat/lon 0/0

* use a reference (even though the compiler would have optimized that away)

* rename to googletakeout

* fix docs

* Address code review requests

* add `googletakeout.h` to HEADERS
* convert most `#define`s to static members
* don't pollute global namespace
* rename logging functions
* convert some methods to static functions for clang-tidy
* `title_case` loop by reference instead of by index (clang-tidy)
* better use of debugging levels
* drop dead simplifiedRawPath code for now
* drop empty tracks
* default constructor for GoogleTakeoutInputStream
* add some tests that check the content of the data

Also, I found some unofficial documentation about the location history
format and added that (thanks @CarlosBergillos !)

* apply @tsteven4 's patch. thank you!!

* add license

* fix logging

* As I assigned the correct license to my code, I am skeptical that this makes a difference, but give Robert co-copyright.

* make the test more boring

* rm xml_slice

* revert constructor change from @tsteven4 's patch

* apply @tsteven4 's latest constructor

* apply @tsteven4 's latest patch -- `cmake --build . --target check` passes

---------

Co-authored-by: tsteven4 <13596209+tsteven4@users.noreply.github.com>
16 files changed:
.gitignore
CMakeLists.txt
googletakeout.cc [new file with mode: 0644]
googletakeout.h [new file with mode: 0644]
reference/format0.txt
reference/format1.txt
reference/format2.txt
reference/format3.txt
reference/googletakeout/2013/2013_JUNE.json [new file with mode: 0644]
reference/googletakeout/2013/2013_MAY.json [new file with mode: 0644]
reference/googletakeout/googletakeout.gpx [new file with mode: 0644]
reference/help.txt
testo
testo.d/googletakeout.test [new file with mode: 0644]
vecs.cc
xmldoc/formats/googletakeout.xml [new file with mode: 0644]